# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
  helper :all # include all helpers, all the time
  protect_from_forgery # See ActionController::RequestForgeryProtection for details

  # Scrub sensitive parameters from your log
  # filter_parameter_logging :password
   def addTolog(user,action)
      @logtmp=Log.new(:utilisateur_id => user, :action => action)
      @logtmp.save
  end
 
  protected
  include ApplicationHelper
  def check_authentication
    return true if authenticated?
    route_to_login 'Veuillez-vous authentifier pour utiliser l\'application'
  end
  
  
  def route_to_login(message = nil)
  flash[:error] = message if message
  session[:original_uri] = request.request_uri if request.get?
  redirect_to login_url
  end
 
 
end
